import { reactive } from 'vue'
import System from '~/utils/System'
import SSys from './SSys'
import SUser from './SUser'

const SStore = reactive({
    //初始化数据，从请求、缓存中初始化
    init: async () => {
        const token = SUser.getToken()
        if (StrUtil.isNull(token)) {
            System.router.push('/login')
            return
        }
        await SSys.getMenuList()
        await SSys.getApiList()
    },
    clearUserInfo: () => {
        SUser.setToken('')
        SSys.setMenuList([], [])
        SSys.setApiList([])
    }
})

export default SStore
